package domain;

import java.util.Scanner;

public class MemoryGame {

	Card c;
	private int pair=0,click=0;
	private int r1=0,c1=0,r2=0,c2=0;
	//public static Scanner in;
	
	public void playGame(int rowCount,int colCount) {
		Board board=new Board();
		board.initBoard(rowCount,colCount);
	
		Scanner in = new Scanner(System.in);
		
		while(pair!=(rowCount*colCount/2)){
			try{
				System.out.println("enter first row then column between 0 and "+(rowCount-1));
	
				// Reads a single line from console 
				// and stores into name variable
				r1 = in.nextInt();
				c1 = in.nextInt();
				r2 = in.nextInt();
				c2 = in.nextInt();
	
				// the variables that is taken from console determine position of two cards on board
				Card a = board.getBoard(r1, c1);
				Card b = board.getBoard(r2, c2);
	
				if(a==b){
					System.out.println("correct!");
					pair++;
					click=click+2;
				}else{
					System.out.println("wrong");
					click=click+2;
				}
			}
			catch(ArrayIndexOutOfBoundsException e){
				System.out.println("Please give a number between 0 and "+rowCount+"!");
			}
		}

		System.out.println("You found : "+pair+" pairs");
		System.out.println("Click count : "+click);
		
		in.close();
		
		
	}
	
	
}
